package com.heima.wemedia.listener;

import com.heima.wemedia.service.WmNewsAutoScanService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class AutoScanNewsListener {
    @Autowired
    private WmNewsAutoScanService wmNewsAutoScanService;
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "autoscan_news",durable = "true"),
            exchange = @Exchange(name = "dl.direct"),
            key = "scannews"
            )
    )
    public void receiveScanNewId(Integer newsId){
        log.info("开始处理文章：{}",newsId);
        wmNewsAutoScanService.autoScanWmNews(newsId);
    }
}
